package com.yeyks.controller.platform;

import com.yeyks.annotation.AdminAppLog;
import com.yeyks.common.appcommon.dto.platform.AppFeedbackDTO;
import com.yeyks.common.appcommon.param.platform.QueryFeedbackParam;
import com.yeyks.common.appcommon.param.platform.SetFeedbackParam;
import com.yeyks.common.appcommon.result.CommonPage;
import com.yeyks.common.appcommon.result.CommonResult;
import com.yeyks.consumer.service.FeedbackService;
import com.yeyks.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import static com.yeyks.common.constants.SysLogMsg.FEEDBACK_UPDATE;

/**
 * @author: gui
 * @date: 2019/5/29 0029 10:43
 */
@Api(tags = "AppFeedBackController_反馈接口", description = "反馈的相关列表信息【是否已读】")
@RestController
@RequestMapping("/platform/feedback")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AppFeedbackController extends BaseController {

    private final FeedbackService feedbackService;

    @ApiOperation("分页查询反馈信息接口【未读】【全部】")
    @PostMapping("/list")
    public CommonResult<CommonPage<AppFeedbackDTO>> list(@Valid QueryFeedbackParam param) {

        validToken(param.getToken(), param.getVersion(), param.getPlatform());

        return feedbackService.queryPageByParam(param);
        //return feedbackService.list(param);
    }

    @AdminAppLog(value = FEEDBACK_UPDATE)
    @ApiOperation("设置反馈信息为已读")
    @PostMapping("/read")
    public CommonResult readFeedback(@Valid SetFeedbackParam setFeedbackParam) {

        validToken(setFeedbackParam.getToken(), setFeedbackParam.getVersion(), setFeedbackParam.getPlatform());

        return feedbackService.readFeedback(setFeedbackParam);
        //return feedbackService.readFeedback(token, id, version, platform);
    }

}
